/**
 * 建造者模式
 *
 * 创建一个求职人员的信息
 * 求职的简历包括姓名、职位、技能、爱好特长等属性
 */

class Person {
  constructor(name, work) {
    this.name = new Name(name);
    this.work = new Work(work);
  }
}

class Work {
  constructor(work) {
    switch (work) {
      case "code":
        this.work = "developer";
        this.workDescription = "code every day";
        break;
      case "UI":
      case "UE":
        this.work = "UI Designer";
        this.workDescription = "design every day";
        break;
      default:
        this.workDescription = "no description";
        this.work = work;
    }
  }

  changeWorkDesc(desc) {
    this.workDescription = desc;
  }
}

class Name {
  constructor(name) {
    this.wholeName = name;
    this.firstName = name.split(" ")[0];
    this.secondName = name.split(" ")[1];
  }
}

let person = new Person("PENG BO", "code");
console.log(person.name.firstName);
console.log(person.work.workDescription);
console.log(person.work.work);
